package com.qf.qfleadnewscommons.sms;

import com.aliyun.tea.TeaException;

public class SmsOperator {
    private com.aliyun.dysmsapi20170525.Client client;
    private SmsProperties properties;
    public SmsOperator(com.aliyun.dysmsapi20170525.Client client,SmsProperties properties){
        this.client = client;
        this.properties = properties;
    }

    public void send(String phone,String code){
        com.aliyun.dysmsapi20170525.models.SendSmsRequest sendSmsRequest = new com.aliyun.dysmsapi20170525.models.SendSmsRequest()
                .setSignName(properties.getSignname())
                .setTemplateCode(properties.getTemplatecode())
                .setPhoneNumbers(phone)
                .setTemplateParam("{\"code\":\""+code+"\"}");
        com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
        try {
            // 复制代码运行请自行打印 API 的返回值
            client.sendSmsWithOptions(sendSmsRequest, runtime);
        } catch (TeaException error) {
            // 如有需要，请打印 error
            com.aliyun.teautil.Common.assertAsString(error.message);
        } catch (Exception _error) {
            TeaException error = new TeaException(_error.getMessage(), _error);
            // 如有需要，请打印 error
            com.aliyun.teautil.Common.assertAsString(error.message);
        }
    }
}
